package com.luyou.framework.banner.core;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import java.net.InetAddress;

/**
 * @author weiqi
 * @version 1.0
 * @date 2024/6/30 19:11
 * @desc
 */
@Component
public class LuyouBannerApplicationRunner implements ApplicationRunner {

//    @Autowired
//    private Environment env;
    @Value("${server.port}")
    private String port;


    @Override
    public void run(ApplicationArguments args) throws Exception {
        String hostAddress = InetAddress.getLocalHost().getHostAddress();
//        String port = env.getProperty("server.port");
        String projectUrl = "http://" + hostAddress + ":" + port;
        System.out.println("项目访问地址=>" + projectUrl);
//        System.out.println("项目文档地址=>" + projectUrl + "/swagger-ui.html");
        //为啥突然变成下面这个。后面再说
        System.out.println("项目文档地址=>" + projectUrl + "/swagger-ui/index.html");
    }
}
